package javaStudy.线程.线程控制;

public class ThreadSleepDemo {
    public static void main(String[] args) {
        ThreadSleep ts1 = new ThreadSleep();
        ThreadSleep ts2 = new ThreadSleep();
        ThreadSleep ts3 = new ThreadSleep();
        ts1.setName("孙权");
        ts2.setName("曹操");
        ts3.setName("刘备");


        //设置守护线程，当运行程序都是守护线程时，Java虚拟机将退出
//        ts1.setDaemon(true);
//        ts2.setDaemon(true);
//        ts3.setDaemon(true);
//        //设置主线程为大哥
//        Thread.currentThread().setName("大哥");
//        for (int i=0;i<10;i++){
//            System.out.println(Thread.currentThread().getName()+":"+i);
//        }


        ts1.start();


//        try {
//            //这个线程执行完，其他线程才可以执行
//            ts1.join();
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        }


        ts2.start();
        ts3.start();

    }
}
